#ifndef __TRACK_FORM
#define __TRACK_FORM

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <ActnList.hpp>
#include <Dialogs.hpp>

#include "ozf_Base.h"
#include "HWindow.h"
#include "HRectButton.h"
#include "HSpacer.h"
#include "HMenus.h"
#include "HLog.h"
#include "BkList.h"
#include "HPaintScroll.h"
#include "TB97Ctls.hpp"
#include "HDesignPanel.h"
#include "HGrid.h"
#include <Grids.hpp>

//---------------------------------------------------------------------------
class TTrackForm : public TOziBaseForm {
  __published:
        HPopupMenu *imagePopup;
        TMenuItem *mnuInsertPoint;
        TMenuItem *N1;
        TMenuItem *D1;
        TMenuItem *S1;
        TMenuItem *i2;
        TMenuItem *D2;
        TMenuItem *A1;
        TMenuItem *N2;
        TMenuItem *C1;
        TActionList *ActionList1;
        TAction *aDrawInfo;
        TAction *aCfg;
        TAction *aMoveLeft;
        TAction *aMoveUp;
        TAction *aMoveRight;
        TAction *aMoveDown;
        TAction *aMoveReset;
        TMenuItem *D3;
        TAction *aTrackAdd;
        TAction *aZoomInc;
        TAction *aZoomDec;
        TStatusBar *hlpStatus;
        HPopupMenu *overridePopup;
        TMenuItem *D4;
        HPopupMenu *pPopup;
        TMenuItem *D5;
        TMenuItem *mnuOverride;
        TTimer *SaveTimer;
        TMenuItem *mnuPEdit;
        HWindow *wndPlaces;
        HPaintScrollBox *HPaintScrollBox1;
        HPaintScrollBox *image;
        TStatusBar *status;
        HWindow *wndPoints;
        HWindow *wndControls;
        HRectButton *HRectButton6;
        HRectButton *HRectButton7;
        HRectButton *HRectButton10;
        HRectButton *HRectButton8;
        HRectButton *HRectButton9;
        HSpacer *HSpacer2;
        HRectButton *btnLoad;
        HRectButton *btnSave;
        HRectButton *btnAutoMove;
        HRectButton *btnLogTrack;
        HLogComboBox *cbScale;
        TPanel *Panel1;
        TToolbarButton97 *btnWPAdd;
        TToolbarButton97 *btnWPDel;
        TToolbarButton97 *btnWPEdit;
        TToolbarButton97 *btnWPClear;
        HPopupMenu *wpPopup;
        TMenuItem *MenuItem1;
        TMenuItem *MenuItem2;
        TMenuItem *mnuWPOverride;
        TPanel *Panel2;
        TToolbarButton97 *ToolbarButton971;
        TToolbarButton97 *ToolbarButton972;
        TToolbarButton97 *ToolbarButton974;
        TAction *aTrackClear;
        TAction *aLoad;
        TAction *aSave;
        HSpacer *HSpacer1;
        TAction *aTrackDel;
        TAction *aWPAdd;
        TAction *aWPDel;
        TAction *aWPEdit;
        TAction *aWPClear;
        HGrid *pList;
        HRectButton *btnZoomOut;
        HRectButton *btnZoomIn;
        TMenuItem *N3;
        TMenuItem *N4;
        TAction *aTrackEdit;
        TToolbarButton97 *ToolbarButton973;
        TAction *aTrackGo;
        TToolbarButton97 *ToolbarButton975;
        TMenuItem *Positiontotrackstartpoint1;
        TMenuItem *N5;
        TAction *aWPGo;
        TMenuItem *Positiontowaypointcoordinates1;
        TMenuItem *N6;
        TMenuItem *Addwaypoint1;
        TMenuItem *N7;
        TMenuItem *N8;
        TToolbarButton97 *ToolbarButton976;
        HGrid *wpList;
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall idOnButton(TObject *Sender,
          const PHCustomWindowBorder Border,
          const HCaptionButton_t Button);
        void __fastcall idScaleChange(TObject *Sender);
        void __fastcall clientResize(TObject *Sender);
        void __fastcall imagePopupMenuItemCheck(TObject *Sender,
          TMenuItem *Item);
        void __fastcall mnuInsertPointClick(TObject *Sender);
        void __fastcall S1Click(TObject *Sender);
        void __fastcall i2Click(TObject *Sender);
        void __fastcall D2Click(TObject *Sender);
        void __fastcall A1Click(TObject *Sender);
        void __fastcall aDrawInfoExecute(TObject *Sender);
        void __fastcall aCfgExecute(TObject *Sender);
        void __fastcall idMoveLeft(TObject *Sender);
        void __fastcall idMoveUp(TObject *Sender);
        void __fastcall idMoveRight(TObject *Sender);
        void __fastcall idMoveDown(TObject *Sender);
        void __fastcall idMoveReset(TObject *Sender);
        void __fastcall D3Click(TObject *Sender);
        void __fastcall aTrackAddExecute(TObject *Sender);
        void __fastcall aZoomIncExecute(TObject *Sender);
        void __fastcall aZoomDecExecute(TObject *Sender);
        void __fastcall imagePaint(TObject *Sender, TCanvas *dc);
        void __fastcall imageMouseDown(TObject *Sender,
          TMouseButton Button, TShiftState Shift, int X, int Y);
        void __fastcall imageMouseMove(TObject *Sender, TShiftState Shift,
          int X, int Y);
        void __fastcall overridePopupPopup(TObject *Sender);
        void __fastcall D4Click(TObject *Sender);
        void __fastcall aDelCurPointExecute(TObject *Sender);
        void __fastcall pPopupMenuItemCheck(TObject *Sender,
          TMenuItem *Item);
        void __fastcall SaveTimerTimer(TObject *Sender);
        void __fastcall idLoad(TObject *Sender);
        void __fastcall idSave(TObject *Sender);
        void __fastcall idAutoMove(TObject *Sender);
        void __fastcall idLogTrack(TObject *Sender);
        void __fastcall FormKeyUp(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall statusDrawPanel(TStatusBar *StatusBar,
          TStatusPanel *Panel, const TRect &Rect);
        void __fastcall imageResize(TObject *Sender);
        void __fastcall wpListMouseDown(TObject *Sender,
          TMouseButton Button, TShiftState Shift, int X, int Y);
        void __fastcall wpPopupMenuItemCheck(TObject *Sender,
          TMenuItem *Item);
        void __fastcall FormKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift);
        void __fastcall aTrackClearExecute(TObject *Sender);
        void __fastcall aWPAddExecute(TObject *Sender);
        void __fastcall aWPDelExecute(TObject *Sender);
        void __fastcall aWPEditExecute(TObject *Sender);
        void __fastcall aWPClearExecute(TObject *Sender);
        void __fastcall pListHOnGetCellText(TObject *Sender, int nX,
          int nY, AnsiString &Value);
        void __fastcall pListHOnCellClick(TObject *Sender,
          PHCustomGridCell Cell, TMouseButton Button, TShiftState Shift,
          int mX, int mY, int nX, int nY);
        void __fastcall pListHOnHeaderMove(TObject *Sender,
          PHCustomGridCell Cell, TShiftState Shift, int mX, int mY, int nX,
          int nY);
        void __fastcall pListClick(TObject *Sender);
        void __fastcall aTrackEditExecute(TObject *Sender);
        void __fastcall aTrackGoExecute(TObject *Sender);
        void __fastcall aWPGoExecute(TObject *Sender);
        void __fastcall wpListHOnGetCellText(TObject *Sender, int nX,
          int nY, AnsiString &Value);
        void __fastcall wpListHOnCellClick(TObject *Sender,
          PHCustomGridCell Cell, TMouseButton Button, TShiftState Shift,
          int mX, int mY, int nX, int nY);
        void __fastcall wpListHOnHeaderMove(TObject *Sender,
          PHCustomGridCell Cell, TShiftState Shift, int mX, int mY, int nX,
          int nY);
        void __fastcall pListHOnHeaderClick(TObject *Sender,
          PHCustomGridCell Cell, TMouseButton Button, TShiftState Shift,
          int mX, int mY, int nX, int nY);
        void __fastcall wpListHOnHeaderClick(TObject *Sender,
          PHCustomGridCell Cell, TMouseButton Button, TShiftState Shift,
          int mX, int mY, int nX, int nY);
  protected:
    virtual void __fastcall idPos( double Lat,double Lon,double vSpeed,double Head,double Mag,double Alt, int x, int y );

  protected:
    void __fastcall idOverrideChange( TObject *Sender );

  private:
    Windows::TPoint CursorPos;
    int             ShinePoint, ShineLine;
    time_t          LastSave;
    TrackOptions    op;

  public:
    __fastcall TTrackForm(TComponent* Owner);

    void RefreshOptions( void );
    void Refresh( void );
    void SetSizes( void );

    int  DrawY( int y );
    int  DrawX( int x );
    int  FieldX( int x );
    int  FieldY( int y );

    void DrawCoordLine( TCanvas *dc,int lNum, bool isCurrent, bool isLast );
    void DrawLineInfo( TCanvas *dc, PHCoordLine l );
    int  LocateLinePoint( int x, int y, int& l );

    void Save( CONSTSTR nm );
    void Load( CONSTSTR nm, bool StopLogging = true );

     DEF_PROP_P( PHCoordLine, ListItem,    ; )
     DEF_PROP_P( PHCoord,     CurPlace,    ; )

    DEF_PROP_VP( int,         Scale,       ; )
    DEF_PROP_VP( int,         CurrentLine, ; )
    DEF_PROP_VP( int,         OffsetX,     ; )
    DEF_PROP_VP( int,         OffsetY,     ; )
    DEF_PROP_VP( bool,        AutoMove,    ; )
    DEF_PROP_VP( bool,        LogTrack,    ; )
};

#endif
